<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="themes/js/jquery-1.9.1.js" type="text/javascript"></script>
<style type="text/css" >@import url("themes/css/StileSettings.css"); </style>
<title>Insert title here</title>
</head>
<body>
<div class="containerSettings">
	<div class="settingsTitle">
	
		<h1>Settings</h1>
	
	</div>
	
	<div class="ResetNamesContainer">
		<b>Reset The Names Database</b> <br><br><br>
			<a href="#" class="button" title="Click if you want to Delete all the names and restart from 0 names" onclick="deleteEntireDB();">Reset entire Names DB</a>
			<br><br><br>
			<a href="#" class="button" title="Click if you want to Reset the statistics about how many objects have been processed" onclick="resetStatistics();">Reset the statistics</a>
			<br><br><br>
			<a href="#" class="button" title="Click if you want to Delete all the extra-info, like DBpedia-Character or Eclap-User info" onclick="deleteExtraInfo()">Reset extra-infos of names</a>
			<br><br><br>

		
	</div>



<script>
function deleteEntireDB(){
	var confirmation=confirm('Do you really want to delete entire names-db and the related info?');
	if (confirmation){
		//allora ha cliccato ok
		$.ajax({
		      url: "ResetDBNomiServlet",
		      type: "post",
		      async: false,
		      cache: false,
		      timeout: 30000,
		      data: {type:"eraseAllExtractedName"},
		      success: function(data,status){
		    	  if(data.indexOf("Errore nelle impostazioni! Forse non si è fatto il login, riprovare!") !== -1){
	            	  alert(data);
	              }else{
		    	  alert("Done: the server has deleted all names, related info and and wiped out the dates of the analyzed objects.")
	              console.log("Il server ha cancellato l'intero DB dei nomi"); 
	              serverOk=true;
	              }
	             
	          },
		      error:function(){
		          alert("Il server ha risposto con un errore");
		          serverOk=false;
		         
		      }   
		    });
	}
	else{
		//allora ha cliccato annulla
	}
	
}
function resetStatistics(){
	var confirmation=confirm('Do you really want to reset dates of analyzed objects?');
	if (confirmation){
		//allora ha cliccato ok
		$.ajax({
		      url: "ResetDBNomiServlet",
		      type: "post",
		      async: false,
		      cache: false,
		      timeout: 30000,
		      data: {type:"eraseNameExtractionDate"},
		      success: function(data,status){
		    	  if(data.indexOf("Errore nelle impostazioni! Forse non si è fatto il login, riprovare!") !== -1){
	            	  alert(data);
	              }else{
		    	  alert("Done: the server has wiped out the dates of the analyzed objects.")
	              console.log("Il server ha resettato le date degli oggetti analizzati"); 
		    	  
	              serverOk=true;
	              }
	          },
		      error:function(){
		          alert("Il server ha risposto con un errore");
		          serverOk=false;
		         
		      }   
		    });
	}
	else{
		//allora ha cliccato annulla
	}
	
}

function deleteExtraInfo(){
	var confirmation=confirm('Do you really want to delete the extra-infos of all objects?');
	if (confirmation){
		//allora ha cliccato ok
		$.ajax({
		      url: "ResetDBNomiServlet",
		      type: "post",
		      async: false,
		      cache: false,
		      timeout: 30000,
		      data: {type:"eraseAllExtraInfo"},
		      success: function(data,status){
		    	  if(data.indexOf("Errore nelle impostazioni!") != -1){
	            	  alert(data);
	              }else{
		    	  alert("Done: the server has deleted the extra-infos of all objects.")
	              console.log("Il server ha cancellato tutte le extra-info degli oggetti"); 
	              serverOk=true;
	              }
	          },
		      error:function(){
		          alert("Il server ha risposto con un errore");
		          serverOk=false;
		         
		      }   
		    });
	}
	else{
		//allora ha cliccato annulla
	}
	
}

</script>

</div>
</body>
</html>